<template>
  <div class="iconMin">
    <div class="backBtn" v-if="!icon">
      <van-button type="default" icon="arrow-left" @click="goto"></van-button>
    </div>
    <van-icon name="arrow-left" @click="goto" v-else style="margin-top: 0.325rem;" />
  </div>
</template>
<script>
export default {
  props: {
    icon: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {};
  },
  methods: {
    goto() {
      if (this.fun.isCPS()) {
        if (this.fun.isIosOrAndroid() === "ios") {
          routeBackUrlIOS({ body: "routeBackUrlIOS" });
        } else {
          routeBackUrlAndroid();
        }
        return;
      }

      try {
        if(this.$route.name == 'drinkMachindIndex'){
          this.$router.push(this.fun.getUrl("home", {}));
        } else if (window.history.length <= 1) {
          this.$router.push(this.fun.getUrl("home", {}));
        } else {
          this.$router.go(-1);
        }
      } catch (error) {
        this.$router.push(this.fun.getUrl("home", {}));
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.iconMin {
  display: inline-block;
  overflow: hidden;
}

.backBtn {
  flex-shrink: 0;
  height: 100%;
  padding-left: 0.625rem;

  .van-button {
    border: none;
    padding: 0;
    font-size: 16px;
    height: 38px;
  }
}
</style>
